Imports System.Windows.Forms
Namespace Controls
    Public Class BarContainerSettingSelector

        Private WithEvents mSettings As New BarContainerSettingCollection

        Sub New(ByRef Settings As BarContainerSettingCollection)
            MyBase.New()

            mSettings = Settings.Sort(mSettings)

            'mSettings.Sort()

            Me.InitializeComponent()
        End Sub

        Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            Me.BarContainerSettingCollectionBindingSource.Sort = ""
            Me.BarContainerSettingCollectionBindingSource.DataSource = Nothing
            mSettings.UpdateRate = Me.uxUpDnRate.Value
            mSettings = Nothing
            Me.Close()
        End Sub

        Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
            Me.BarContainerSettingCollectionBindingSource.Sort = ""
            Me.BarContainerSettingCollectionBindingSource.DataSource = Nothing
            mSettings = Nothing
            Me.Close()
        End Sub

        Private Sub BarContainerSettingSelector_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Me.BarContainerSettingCollectionBindingSource.RaiseListChangedEvents = True
            Me.BarContainerSettingCollectionBindingSource.DataSource = mSettings
            Me.BarContainerSettingCollectionBindingSource.Sort = "Name"
            Me.uxUpDnRate.Value = mSettings.UpdateRate
        End Sub

        Private Sub uxGraphSettings_DataError(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles uxDataGrid.DataError
            e.ThrowException = False
        End Sub

    End Class
End Namespace
